use tauri::command;
use crate::types::ApiResponse;

#[command]
pub fn to_upper_case(input: String) -> ApiResponse {
    ApiResponse::success(input.to_uppercase())
}

#[command]
pub fn to_lower_case(input: String) -> ApiResponse {
    ApiResponse::success(input.to_lowercase())
}

#[command]
pub fn to_title_case(input: String) -> ApiResponse {
    let mut result = String::new();
    let mut capitalize = true;

    for c in input.chars() {
        if c.is_whitespace() {
            capitalize = true;
            result.push(c);
        } else if capitalize {
            result.push(c.to_uppercase().next().unwrap());
            capitalize = false;
        } else {
            result.push(c.to_lowercase().next().unwrap());
        }
    }

    ApiResponse::success(result)
} 